Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 vector-feature-night-mode-enabled skin-theme-clientpref-os vector-sticky-header-enabled" lang="fr" dir="ltr"><head>
<meta charset="UTF-8">
<title>Optimisation de code</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./_res_/favicon.png">
<link rel="canonical" href="https://fr.wikipedia.org/wiki/Optimisation_de_code"> <link href="./_mw_/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
<link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
<link rel="stylesheet" type="text/css" href="./_res_/footer.css">
<link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Optimisation_de_code rootpage-Optimisation_de_code skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Optimisation de code</span></h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="contentSub">
<div id="mw-content-subtitle"></div>
</div>
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="fr" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="fr" dir="ltr"><p>En <a href="Programmation" class="mw-redirect" title="Programmation">programmation</a> <a href="Informatique" title="Informatique">informatique</a>, <b>l'optimisation de code</b> est la pratique consistant à améliorer l'efficacité du <a href="Code_informatique" class="mw-redirect" title="Code informatique">code informatique</a> d'un programme ou d'une bibliothèque logicielle. Ces améliorations permettent généralement au programme résultant de s'exécuter plus rapidement, de prendre moins de place en <a href="M%C3%A9moire_(informatique)" title="Mémoire (informatique)">mémoire</a>, de limiter sa consommation de ressources (par exemple les <a href="Fichier_informatique" title="Fichier informatique">fichiers</a>), ou de consommer moins d'<a href="%C3%89nergie_%C3%A9lectrique" title="Énergie électrique">énergie électrique</a>.
</p>

<div class="mw-heading mw-heading2"><h2 id="Principes_d'optimisation"><span id="Principes_d.27optimisation"></span>Principes d'optimisation</h2></div>
<p>La règle numéro un de l'optimisation est qu'<i>elle ne doit intervenir qu'une fois que le programme fonctionne et répond aux spécifications fonctionnelles</i>. L'expérience montre qu'appliquer des optimisations de bas niveau du code avant que ces deux conditions ne soient réalisées revient le plus souvent à une perte de temps et s'avère néfaste à la clarté du code et au bon fonctionnement du programme&nbsp;:
</p>
<blockquote>
<p>«&nbsp;L'optimisation prématurée est la source de tous les maux.&nbsp;»
</p>
</blockquote><p style="margin:-0.7em 0 0.3em 6em">—&nbsp;<a href="Donald_Knuth" title="Donald Knuth">Donald Knuth</a>, <cite>citant <a href="Edsger_Dijkstra" title="Edsger Dijkstra">Dijkstra</a></cite></p>
<p>Cependant cette citation, tronquée, est très souvent mal interprétée. La version complète étant&nbsp;:
</p>
<blockquote>
<p>«&nbsp;On devrait oublier les petites optimisations locales, disons, 97&nbsp;% du temps&nbsp;: l'optimisation prématurée est la source de tous les maux<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>.&nbsp;»
</p>
</blockquote><p style="margin:-0.7em 0 0.3em 6em">—&nbsp;<a href="Donald_Knuth" title="Donald Knuth">Donald Knuth</a></p>
<p>La citation originale indique que généralement durant l'écriture d'un code, on peut laisser de côté les optimisations locales, de bas niveau (réécriture en assembleur, <a href="D%C3%A9roulage_de_boucle" title="Déroulage de boucle">déroulage de boucle</a>, etc.). Il est possible d'interpréter cette citation en déduisant de celle-ci que les optimisations de haut niveau concernant le choix des algorithmes ou l'architecture d'un projet doivent venir avant celle de bas niveau. Ainsi, ce n'est que vers la fin de l'écriture du programme, une fois que l'analyse montre qu'un détail de bas niveau est critique qu'il peut éventuellement être nécessaire de le modifier&nbsp;:
</p>
<blockquote>
<p>«&nbsp;What Hoare and Knuth are really saying is that software engineers should worry about other issues (such as good algorithm design and good implementations of those algorithms) before they worry about micro-optimizations such as how many CPU cycles a particular statement consumes.&nbsp;»
</p>
</blockquote><p style="margin:-0.7em 0 0.3em 6em">—&nbsp;Randall Hyde, <cite>ACM Ubiquity Vol. 10, Issue 3 </cite></p>
<p>Au contraire plus le projet grandit et plus ces optimisations de haut niveau seront difficiles, coûteuses (en termes de temps, difficulté et budget) voire impossibles à effectuer.
</p><p>La plupart des <a href="Compilateur" title="Compilateur">compilateurs</a> récents pratiquent de façon automatique un certain nombre d'optimisations qu'il serait fastidieux d'effectuer <i>manuellement</i> et qui rendraient le <a href="Code_source" title="Code source">code source</a> moins <a href="Lisibilit%C3%A9_(programmation)" title="Lisibilité (programmation)">lisible</a>.
</p><p>L'optimisation manuelle locale peut s'avérer nécessaire dans des cas très spécifiques, mais les mesures montrent que sur des machines <a href="Reduced_instruction_set_computer" class="mw-redirect" title="Reduced instruction set computer">RISC</a> qui possèdent un nombre élevé de <a href="Registre_(informatique)" class="mw-redirect" title="Registre (informatique)">registres</a> et où l'efficacité demande le regroupement des instructions identiques pour bénéficier de l'effet <a href="Pipeline_(architecture_des_processeurs)" title="Pipeline (architecture des processeurs)">pipeline</a>, l'optimiseur d'un compilateur C fournit souvent un code plus efficace que celui qui serait écrit en <a href="Langage_assembleur" class="mw-redirect" title="Langage assembleur">assembleur</a> par un programmeur expérimenté (ce qui n'était jamais le cas sur les machines <a href="Complex_instruction_set_computer" class="mw-redirect" title="Complex instruction set computer">CISC</a>). Et de surcroit ce code est bien plus facile à maintenir, car les instructions en C restent dans un ordre lié à la seule intelligibilité du code et non aux spécificités de la machine&nbsp;: dans les optimiseurs actuels, en effet, les ordres machines associés à une instruction ne se trouvent plus nécessairement en position contiguë, pour des raisons d'efficacité d'exécution. Cela rend le code assembleur généré particulièrement indéchiffrable.
</p>
<div class="mw-heading mw-heading2"><h2 id="Pratique_de_l'optimisation"><span id="Pratique_de_l.27optimisation"></span>Pratique de l'optimisation</h2></div>
<p>Pour suivre l’efficacité d’une optimisation, le développeur s’appuie sur des <a href="Test_de_performance" title="Test de performance">tests de performance</a>, c’est-à-dire sur des mesures objectives du temps de traitement et de la taille de la <a href="M%C3%A9moire_vive" title="Mémoire vive">mémoire</a> <a href="Allocation_de_m%C3%A9moire" title="Allocation de mémoire">allouée</a>.
</p><p>La réduction de la <a href="Resident_set_size" title="Resident set size">taille des données résidentes en mémoire</a> est complexe puisque la libération d’une zone de mémoire permet rarement de rendre la mémoire disponible pour le système d’exploitation<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Localisation_du_code_à_optimiser"><span id="Localisation_du_code_.C3.A0_optimiser"></span>Localisation du code à optimiser</h3></div>

<p>Pour évaluer le <a href="Worst_Case_Execution_Time" title="Worst Case Execution Time">temps</a> et la <a href="M%C3%A9moire_virtuelle" title="Mémoire virtuelle">mémoire</a> nécessaire pour chaque partie du programme, les développeurs réalisent le <a href="Profilage_de_code" class="mw-redirect" title="Profilage de code">profilage du code</a>. Il n'est pas rare qu’une grande partie du temps soit consacré à l'exécution d’un petit morceau du code, ce morceau de code est appelé «&nbsp;<a href="Goulot_d'%C3%A9tranglement_(informatique)" title="Goulot d'étranglement (informatique)">goulot d’étranglement</a>&nbsp;».
</p><p>Le logiciel de profilage est chargé de compter le nombre d’exécutions de chaque fonction et de cycles du <a href="Microprocesseur" title="Microprocesseur">microprocesseur</a> correspondants au cours de l'exécution.
</p>
<div class="mw-heading mw-heading3"><h3 id="Différentes_approches_d’optimisation"><span id="Diff.C3.A9rentes_approches_d.E2.80.99optimisation"></span>Différentes approches d’optimisation</h3></div>
<p>Plusieurs approches existent pour optimiser un code&nbsp;:
</p>
<ul><li>au niveau algorithmique, en choisissant un <a href="Algorithmique" title="Algorithmique">algorithme</a> de <a href="Th%C3%A9orie_de_la_complexit%C3%A9_(informatique_th%C3%A9orique)" title="Théorie de la complexité (informatique théorique)">complexité mathématique</a> inférieure et des <a href="Structure_de_donn%C3%A9es" title="Structure de données">structures de données</a> adaptées&nbsp;;</li>
<li>au niveau du <a href="Langage_de_programmation" title="Langage de programmation">langage de développement</a>, en ordonnant au mieux les instructions et en utilisant les bibliothèques disponibles&nbsp;;</li>
<li>en utilisant localement un <a href="Langage_de_programmation_de_bas_niveau" title="Langage de programmation de bas niveau">langage de bas niveau</a>, qui peut être le <a href="C_(langage)" title="C (langage)">langage C</a> ou, pour les besoins les plus critiques, le <a href="Langage_assembleur" class="mw-redirect" title="Langage assembleur">langage assembleur</a>.</li></ul>
<div class="mw-heading mw-heading4"><h4 id="Optimisation_algorithmique">Optimisation algorithmique</h4></div>

<p>L’optimisation algorithmique consiste à appliquer au code des transformations mathématiques successives qui préservent la <a href="Sp%C3%A9cification_(norme_technique)" title="Spécification (norme technique)">spécification</a> du programme tout en réduisant la consommation des ressources.
</p>
<div class="mw-heading mw-heading4"><h4 id="Optimisations_grâce_aux_outils_du_langage"><span id="Optimisations_gr.C3.A2ce_aux_outils_du_langage"></span>Optimisations grâce aux outils du langage</h4></div>
<p>L’utilisation de <a href="Routine_(informatique)" title="Routine (informatique)">fonctions</a> différentes voire de <a href="Biblioth%C3%A8que_logicielle" title="Bibliothèque logicielle">bibliothèques</a> complètes différentes peut permettre une optimisation du programme.
</p>
<div class="mw-heading mw-heading4"><h4 id="Optimisation_en_changeant_de_langage_utilisé"><span id="Optimisation_en_changeant_de_langage_utilis.C3.A9"></span>Optimisation en changeant de langage utilisé</h4></div>
<p>Dans la pratique, les applications comportant beaucoup d'<a href="Entr%C3%A9es-sorties" class="mw-redirect" title="Entrées-sorties">entrées-sorties</a> lentes peuvent être optimisées en étant réécrites dans un <a href="Langage_de_programmation" title="Langage de programmation">langage</a> comme <a href="Haskell" title="Haskell">Haskell</a> ou <a href="Python_(langage)" title="Python (langage)">Python</a>.
</p><p>Une application nécessitant beaucoup de calculs et d’<a href="Affectation_(informatique)" title="Affectation (informatique)">affectations en mémoire</a> peut être optimisée en étant réécrite dans un langage tel que le C ou le C++.
</p>
<div class="mw-heading mw-heading2"><h2 id="Optimisation_automatique">Optimisation automatique</h2></div>
<p>Les compilateurs sont souvent capables de faire des optimisations locales, auxquelles aucun développeur ne penserait en première approche.
</p><p>Pour le langage C, cela peut concerner&nbsp;:
</p>
<ul><li>les variables locales et les registres&nbsp;;</li>
<li>les fonctions non implémentées en assembleur en tant que fonction&nbsp;;</li>
<li>les <code>switch</code>, qui sont optimum.</li></ul>
<p>Toutefois, on peut grandement aider le compilateur en déclarant les variables avec les mots-clefs <code>const</code> et/ou <code>restrict</code> quand c'est possible&nbsp;; autrement, le compilateur ne peut savoir si une zone mémoire est accessible par d'autres références, et désactivera des optimisations (phénomène dit d'alias de mémoire).
</p><p>Un profileur (ou un analyseur de performances) peut être utilisé pour trouver les sections du programme qui consomment le plus de ressources - le goulot d'étranglement<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup class="reference cite_virgule">,</sup><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>. Les programmeurs peuvent avoir une idée erronée de l'endroit où se trouve le goulot d'étranglement. L'optimisation d'une partie mineure du code ne contribue généralement pas à améliorer les performances globales.
Lorsque le goulet d'étranglement est localisé, l'optimisation commence généralement par un réexamen de l'algorithme utilisé dans le programme<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>. Le plus souvent, un algorithme particulier peut être spécifiquement adapté à une tâche particulière et offrir de meilleures performances qu'un algorithme générique. Par exemple, le tri d'une énorme liste d'éléments est généralement effectué à l'aide de la procédure de <a href="Tri_rapide" title="Tri rapide">tri rapide</a>, qui est l'un des algorithmes universels les plus efficaces. Mais si certaines caractéristiques des éléments peuvent être exploitées (par exemple, s'ils sont déjà rangés dans un ordre spécifique), une méthode différente ou même une procédure de tri spéciale peut être utilisée.
</p><p>À partir de 2020, des programmes d'optimisation automatique des codes basés sur l'intelligence artificielle commenceront à être utilisés. En proposant différentes manières d'implémenter le code, les outils d'intelligence artificielle peuvent prendre en charge une partie des tâches de l'utilisateur<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>. Par exemple, ces réseaux neuronaux sont capables d'analyser le code, de corriger les erreurs, d'ajouter des lignes ou des branches entières de code<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>.
</p><p>Une fois que le programmeur est suffisamment sûr d'avoir sélectionné le meilleur algorithme, l'optimisation du code peut commencer. Les boucles peuvent être étendues (pour réduire la surcharge des boucles, bien que cela puisse souvent entraîner une dégradation de la vitesse si cela surcharge la mémoire cache de l'unité centrale), le moins de <a href="Type_(informatique)" title="Type (informatique)">types de données</a> possible peut être utilisé, l'arithmétique des nombres entiers peut être utilisée au lieu des opérations à virgule flottante, et ainsi de suite.
</p><p><br>
</p>
<div class="mw-heading mw-heading3"><h3 id="Exemples">Exemples</h3></div>
<div class="mw-heading mw-heading4"><h4 id="Utilisation_de_variables_locales_pour_éviter_les_alias_de_mémoire"><span id="Utilisation_de_variables_locales_pour_.C3.A9viter_les_alias_de_m.C3.A9moire"></span>Utilisation de variables locales pour éviter les alias de mémoire</h4></div>
<p>Le code C++ suivant sera en général peu optimisé par le compilateur car il est souvent incapable de savoir si le code de la boucle modifie ou non le compteur d'itérations&nbsp;: un pointeur ou une référence pourrait le modifier.
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="nf">MyClass::DoSomething</span><span class="p">()</span><span class="w"> </span><span class="k">const</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">m_nbrElements</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="w"> </span><span class="p">)</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">GetSomePtr</span><span class="p">();</span>
<span class="w"> </span><span class="p">....</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
</pre></div>
<p>Dans cette version, on indique clairement qu'on utilise un nombre d'itérations fixé à l'avance et qui ne sera jamais modifié, autorisant le compilateur à effectuer des optimisations plus agressives&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="nf">MyClass::DoSomething</span><span class="p">()</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">nbrElements</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">m_nbrElements</span><span class="p">;</span>
<span class="w"> </span><span class="k">for</span><span class="p">(</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">&lt;</span><span class="n">nbrElements</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="w"> </span><span class="p">)</span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="p">....</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Une_spécificité_du_binaire_:_le_décalage"><span id="Une_sp.C3.A9cificit.C3.A9_du_binaire_:_le_d.C3.A9calage"></span>Une spécificité du binaire&nbsp;: le décalage</h4></div>
<p>Une des toutes premières optimisations a été celle de la division et de la multiplication par une puissance de 2.
</p><p>En effet, l'informatique actuelle repose sur le binaire, puisqu'elle utilise comme élément de base le <a href="Transistor" title="Transistor">transistor</a> (et historiquement, auparavant le <a href="Relais_%C3%A9lectrom%C3%A9canique" title="Relais électromécanique">relais</a>) qui n'autorise que deux valeurs différentes.
</p><p>On a donc logiquement implémenté en <a href="Langage_machine" title="Langage machine">langage machine</a> les opérations de décalage à gauche et décalage à droite.
</p><p>En effet, en <a href="Bit" title="Bit">binaire</a>, le décalage d'un nombre d'un cran vers la gauche le multiplie par 2.
</p>
<dl><dd>Ainsi, 2 (<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 10_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mn>10</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 10_{2}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/113aee51ce51cebc0fd91af88c633e1ca2e08d16.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:3.379ex; height:2.509ex;" alt="{\displaystyle 10_{2}}" loading="lazy"></span>) décalé de 1 bit donne 4 (<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 100_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mn>100</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 100_{2}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/733b5c3ac3e96d091831e49fe297bfb555c5f496.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:4.542ex; height:2.509ex;" alt="{\displaystyle 100_{2}}" loading="lazy"></span>).</dd>
<dd>5 (<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 101_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mn>101</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 101_{2}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/265d75b35b344ee4fd701b0e9cacf30c58d1df1f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:4.542ex; height:2.509ex;" alt="{\displaystyle 101_{2}}" loading="lazy"></span>) décalé de 2 bits donne 20 (<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 10100_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mn>10100</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 10100_{2}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/d6813b0fe8865d06d21553aa9afd681d4791ca11.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.867ex; height:2.509ex;" alt="{\displaystyle 10100_{2}}" loading="lazy"></span>)&nbsp;: <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 5*2^{2}=20}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>5</mn>
<mo>∗<!-- ∗ --></mo>
<msup>
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>=</mo>
<mn>20</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 5*2^{2}=20}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/2a5a5fc9d9a2bcf113e024ad08684cfebcd66693.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:10.997ex; height:2.676ex;" alt="{\displaystyle 5*2^{2}=20}" loading="lazy"></span>.</dd></dl>
<p>Ceci marche aussi pour la division, en décalant les bits vers la droite.
</p>
<dl><dd>100 (<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1100100_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mn>1100100</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1100100_{2}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/3fca7953b49d05568b8733beee62f68a29e7d3f1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:9.191ex; height:2.509ex;" alt="{\displaystyle 1100100_{2}}" loading="lazy"></span>) décalé de 3 bits vers la droite donne <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 100/2^{3}=12.5}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>100</mn>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<msup>
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>3</mn>
</mrow>
</msup>
<mo>=</mo>
<mn>12.5</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 100/2^{3}=12.5}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/5a0d83c407533663464dd6c340d659fed04ebe2f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:14.099ex; height:3.176ex;" alt="{\displaystyle 100/2^{3}=12.5}" loading="lazy"></span> donc 12 (<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1100_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mn>1100</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1100_{2}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/981f5aba2e0ece37fa2fb4e03ca3ae5f64898f9b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:5.704ex; height:2.509ex;" alt="{\displaystyle 1100_{2}}" loading="lazy"></span>) car nous travaillons sur des nombres entiers.</dd></dl>
<p>L'arithmétique entière d'un processeur est en fait l'arithmétique dans l'anneau des <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbb {Z} /2^{32}\mathbb {Z} }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="double-struck">Z</mi>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<msup>
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>32</mn>
</mrow>
</msup>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="double-struck">Z</mi>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \mathbb {Z} /2^{32}\mathbb {Z} }</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/be9673959a197995e2cbec5a9bafd507f17d2501.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:7.302ex; height:3.176ex;" alt="{\displaystyle \mathbb {Z} /2^{32}\mathbb {Z} }" loading="lazy"></span> par exemple. Et donc, tous les nombres premiers avec <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{32}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msup>
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>32</mn>
</mrow>
</msup>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 2^{32}}</annotation>
</semantics>
</math></span><img src="./_assets_/eb734a37dd21ce173a46342d1cc64c92/a8c222ea8e5f187a2bb499395b6f4a6f38b43633.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:3.039ex; height:2.676ex;" alt="{\displaystyle 2^{32}}" loading="lazy"></span> ont un inverse, et il est possible d'effectuer une division par l'un de ces nombres en une seule instruction. Par exemple, dans l'anneau des entiers sur 32 bits, diviser par 3 revient à multiplier par 2863311531. Diviser par 14 revient à multiplier par 3067833783 puis diviser par 2. C'est donc possible avec deux instructions. Les compilateurs savent faire ces optimisations mais pour cela le diviseur doit être connu à la compilation.
</p><p>La division dans le cas général est une instruction coûteuse en temps machine, et n'est d'ailleurs toujours pas disponible sur la grande majorité des processeurs de type <a href="Reduced_instruction_set_computer" class="mw-redirect" title="Reduced instruction set computer">RISC</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Le_mot_clef_inline_du_C">Le mot clef <i>inline</i> du C</h4></div>
<p>Le mot clef <i>inline</i> attaché à une fonction indique au compilateur qu'il devrait essayer d'<a href="Extension_inline" title="Extension inline">étendre cette fonction</a>. Considérons par exemple le code C suivant&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="kr">inline</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="nf">f</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">b</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="nf">g</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">switch</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="mi">10</span><span class="p">:</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="p">);</span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="mi">11</span><span class="p">:</span><span class="w"> </span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="mi">12</span><span class="p">:</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="p">);</span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="mi">1200</span><span class="p">:</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="p">);</span>
<span class="w"> </span><span class="k">default</span><span class="o">:</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
</pre></div>
<p>Une compilation avec gcc -O4 -S donne, en assembleur i386&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-asm mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="na">.file</span><span class="w"> </span><span class="s">"opt.c"</span>
<span class="w"> </span><span class="na">.text</span>
<span class="w"> </span><span class="na">.p2align</span><span class="w"> </span><span class="mi">4</span><span class="p">,,</span><span class="mi">15</span>
<span class="w"> </span><span class="na">.globl</span><span class="w"> </span><span class="no">g</span>
<span class="w"> </span><span class="na">.type</span><span class="w"> </span><span class="no">g</span><span class="p">,</span><span class="w"> </span><span class="na">@function</span>
<span class="w"> </span><span class="nl">g:</span>
<span class="w"> </span><span class="nf">pushl</span><span class="w"> </span><span class="nv">%ebp</span>
<span class="w"> </span><span class="nf">movl</span><span class="w"> </span><span class="nv">%esp</span><span class="p">,</span><span class="w"> </span><span class="nv">%ebp</span>
<span class="w"> </span><span class="nf">movl</span><span class="w"> </span><span class="mi">8</span><span class="p">(</span><span class="nv">%ebp</span><span class="p">),</span><span class="w"> </span><span class="nv">%edx</span>
<span class="w"> </span><span class="nf">cmpl</span><span class="w"> </span><span class="no">$12</span><span class="p">,</span><span class="w"> </span><span class="nv">%edx</span>
<span class="w"> </span><span class="nf">jg</span><span class="w"> </span><span class="no">.L14</span>
<span class="w"> </span><span class="nf">leal</span><span class="w"> </span><span class="mi">-2</span><span class="p">(</span><span class="nv">%edx</span><span class="p">),</span><span class="w"> </span><span class="nv">%eax</span>
<span class="w"> </span><span class="nf">cmpl</span><span class="w"> </span><span class="no">$11</span><span class="p">,</span><span class="w"> </span><span class="nv">%edx</span>
<span class="w"> </span><span class="nf">jge</span><span class="w"> </span><span class="no">.L15</span>
<span class="w"> </span><span class="nf">movl</span><span class="w"> </span><span class="no">$100</span><span class="p">,</span><span class="w"> </span><span class="nv">%eax</span>
<span class="w"> </span><span class="nf">cmpl</span><span class="w"> </span><span class="no">$10</span><span class="p">,</span><span class="w"> </span><span class="nv">%edx</span>
<span class="w"> </span><span class="nl">.L17:</span>
<span class="w"> </span><span class="nf">je</span><span class="w"> </span><span class="no">.L2</span>
<span class="w"> </span><span class="nf">movl</span><span class="w"> </span><span class="nv">%edx</span><span class="p">,</span><span class="w"> </span><span class="nv">%eax</span>
<span class="w"> </span><span class="nl">.L15:</span>
<span class="w"> </span><span class="nf">imull</span><span class="w"> </span><span class="nv">%edx</span><span class="p">,</span><span class="w"> </span><span class="nv">%eax</span>
<span class="w"> </span><span class="nl">.L2:</span>
<span class="w"> </span><span class="nf">popl</span><span class="w"> </span><span class="nv">%ebp</span>
<span class="w"> </span><span class="nf">ret</span>
<span class="w"> </span><span class="na">.p2align</span><span class="w"> </span><span class="mi">4</span><span class="p">,,</span><span class="mi">7</span>
<span class="w"> </span><span class="nl">.L14:</span>
<span class="w"> </span><span class="nf">movl</span><span class="w"> </span><span class="no">$1437600</span><span class="p">,</span><span class="w"> </span><span class="nv">%eax</span>
<span class="w"> </span><span class="nf">cmpl</span><span class="w"> </span><span class="no">$1200</span><span class="p">,</span><span class="w"> </span><span class="nv">%edx</span>
<span class="w"> </span><span class="nf">jmp</span><span class="w"> </span><span class="no">.L17</span>
<span class="w"> </span><span class="na">.size</span><span class="w"> </span><span class="no">g</span><span class="p">,</span><span class="w"> </span><span class="no">.-g</span>
<span class="w"> </span><span class="na">.section</span><span class="w"> </span><span class="no">.note.GNU-stack</span><span class="p">,</span><span class="s">""</span><span class="p">,</span><span class="na">@progbits</span>
<span class="w"> </span><span class="na">.ident</span><span class="w"> </span><span class="s">"GCC: (GNU) 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)"</span>
</pre></div>
<p>Ce qui pourrait se traduire, pour une compréhension plus aisée, par le code C suivant&nbsp;:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="nf">g</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">eax</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">12</span><span class="p">)</span><span class="w"> </span><span class="cm">/* cas a == 1200 */</span>
<span class="w"> </span><span class="k">goto</span><span class="w"> </span><span class="n">L14</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="n">eax</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="mi">11</span><span class="p">)</span><span class="w"> </span><span class="cm">/* cas a == 11 ou a == 12 */</span>
<span class="w"> </span><span class="k">goto</span><span class="w"> </span><span class="n">L15</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="n">eax</span><span class="o">=</span><span class="mi">100</span><span class="p">;</span><span class="w"> </span><span class="cm">/* = 10 * 10 */</span>
<span class="w"> </span><span class="n">b</span><span class="o">=</span><span class="mi">10</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="nl">L17</span><span class="p">:</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"> </span><span class="cm">/* cas a == 10 */</span>
<span class="w"> </span><span class="k">goto</span><span class="w"> </span><span class="n">L2</span><span class="p">;</span>
<span class="w"> </span><span class="cm">/* cas "default" */</span>
<span class="w"> </span><span class="n">eax</span><span class="o">=</span><span class="n">a</span><span class="p">;</span>
<span class="w"> </span><span class="nl">L15</span><span class="p">:</span>
<span class="w"> </span><span class="n">eax</span><span class="o">=</span><span class="n">eax</span><span class="o">*</span><span class="n">a</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="nl">L2</span><span class="p">:</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">eax</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="nl">L14</span><span class="p">:</span>
<span class="w"> </span><span class="n">eax</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1437600</span><span class="p">;</span><span class="w"> </span><span class="cm">/* = 1200*(1200-2) */</span>
<span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1200</span><span class="p">;</span>
<span class="w"> </span><span class="k">goto</span><span class="w"> </span><span class="n">L17</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
</pre></div>
<p>On peut remarquer par exemple que la fonction 'f' n'a pas été générée, mais que son code a directement été incorporé dans la fonction 'g' (le mot clef 'inline' permet de forcer ce type d'optimisation en <a href="C_(langage)" title="C (langage)">C</a>).
</p>
<div class="mw-heading mw-heading2"><h2 id="Notes_et_références"><span id="Notes_et_r.C3.A9f.C3.A9rences"></span>Notes et références</h2></div>
<div class="references-small decimal" style=""><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a> </span><span class="reference-text"><span class="citation not_fr_quote" lang="en">«&nbsp;<span class="italique">We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.</span>&nbsp;»</span></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://redis.io/topics/memory-optimization"><cite style="font-style:normal;" lang="en">Memory Optimization</cite></a>&nbsp;», sur <span class="italique">redis.io</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2020-03-25" data-sort-value="2020-03-25">25 mars 2020</time>)</small></span></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://scoutapm.com/blog/identifying-bottlenecks-and-optimizing-performance-in-a-python-codebase"><cite style="font-style:normal;" lang="en">Identifying bottlenecks and optimizing performance in a Python codebase</cite></a>&nbsp;», sur <span class="italique">scoutapm.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-09-12" data-sort-value="2023-09-12">12 septembre 2023</time>)</small></span></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://likegeeks.com/python-profiling/"><cite style="font-style:normal;" lang="en">Profiling in Python (Detect CPU &amp; memory bottlenecks)</cite></a>&nbsp;», sur <span class="italique">likegeeks.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-09-12" data-sort-value="2023-09-12">12 septembre 2023</time>)</small></span></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><a href="#cite_ref-5">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://pythonspeed.com/articles/logging-vs-profiling/"><cite style="font-style:normal;" lang="en">Finding performance problems: profiling or logging?</cite></a>&nbsp;», sur <span class="italique">pythonspeed.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-09-12" data-sort-value="2023-09-12">12 septembre 2023</time>)</small></span></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><a href="#cite_ref-6">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://www.academickids.com/encyclopedia/index.php/Optimization_%28computer_science%29"><cite style="font-style:normal;" lang="en">Optimization (computer science)</cite></a>&nbsp;», sur <span class="italique">www.academickids.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-09-12" data-sort-value="2023-09-12">12 septembre 2023</time>)</small></span></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><a href="#cite_ref-7">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://www.gate2ai.com/categories/code-assistant"><cite style="font-style:normal;" lang="en">Code Assistant</cite></a>&nbsp;», sur <span class="italique">www.gate2ai.com</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-09-12" data-sort-value="2023-09-12">12 septembre 2023</time>)</small></span></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><a href="#cite_ref-8">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="https://ts2.space/en/improving-code-optimization-with-openai-codexs-neural-networks/"><cite style="font-style:normal;" lang="en">Improving Code Optimization with OpenAI Codex’s Neural Networks</cite></a>&nbsp;», sur <span class="italique">ts2.space</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-09-12" data-sort-value="2023-09-12">12 septembre 2023</time>)</small></span></span>
</li>
</ol></div>
</div>
<div class="mw-heading mw-heading2"><h2 id="Voir_aussi">Voir aussi</h2></div>
<ul><li><a href="Optimisation_de_requ%C3%AAte" title="Optimisation de requête">Optimisation de requête</a></li>
<li><a href="%C3%89valuation_paresseuse" title="Évaluation paresseuse">Évaluation paresseuse</a></li>
<li><a href="Recherche_de_sous-expressions_communes" title="Recherche de sous-expressions communes">Recherche de sous-expressions communes</a></li>
<li><a href="Interpr%C3%A9tation_abstraite" title="Interprétation abstraite">Interprétation abstraite</a></li>
<li><a href="LLVM" title="LLVM">LLVM</a></li>
<li><a href="M%C3%A9moire_cache" title="Mémoire cache">Mémoire cache</a></li>
<li><a href="M%C3%A9mo%C3%AFsation" title="Mémoïsation">Mémoïsation</a></li>
<li><a href="Principe_de_localit%C3%A9_(informatique)" title="Principe de localité (informatique)">Principe de localité</a></li>
<li><a href="Simulation_de_ph%C3%A9nom%C3%A8nes" title="Simulation de phénomènes">Simulation de phénomènes</a></li>
<li><a href="Th%C3%A9orie_des_files_d'attente" title="Théorie des files d'attente">Théorie des files d'attente</a></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Liens_externes">Liens externes</h3></div>
<ul><li><a rel="nofollow" class="external text" href="http://ubiquity.acm.org/article.cfm?id=1513451">The Fallacy of Premature Optimization by Randall Hyde</a> expliquant la citation de Donald Knuth et sa mauvaise interprétation</li>
<li><a rel="nofollow" class="external text" href="http://www.cookcomputing.com/blog/archives/000084.html">Premature Optimization by Charles Cook</a> sur cette même citation de Donald Knuth.</li></ul>
<div class="navbox-container" style="clear:both;">


</div>
<ul id="bandeau-portail" class="bandeau-portail"><li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail de la programmation informatique</span> </span></li> </ul></div><!--htdig_noindex--><div><div class="zim-footer">
Cet article est issu de <a class="external text" title="Dernière modification le 2025-02-11" href="https://fr.wikipedia.org/wiki/?title=Optimisation_de_code&amp;oldid=222914574">Wikipédia</a>. Sauf mention contraire, le texte est disponible sous <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.fr">Creative Commons Attribution-Share Alike 4.0</a>. Des conditions supplémentaires peuvent s’appliquer aux fichiers multimédias.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
<script src="./_webp_/webpHandler.js"></script>

</body></html>